package com.dragon.modules.yuegou.enums.wallet;

import com.fasterxml.jackson.annotation.JsonCreator;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 类型
 * 
 * @author pbuilder generated
 *
 */
public enum MerchantTradeType {

	/**
	 * 扫码
	 */
	SCAN_PAY(0, "扫码"),
	/**
	 * 提货
	 */
	PICK_UP(1, "提货"),
	/**
	 * 退款
	 */
	REFUND(2, "退款"),
	/**
	 * 提现
	 */
	WITHDRAW(3, "提现"),
	/**
	 * 购买
	 */
	BUY(4, "购买"),
	/**
	 * 手续费
	 */
	POUNDAGE(5, "手续费"),
	/**
	 * 运费
	 */
	FREIGHT(6, "运费"),
	/**
	 * 悦卡结算
	 */
	YUECARD(7, "悦卡结算"),
	/**
	 * 悦卡结算
	 */
	ENTITYCARD(8, "实体卡支付");

	/**
	 * 枚举标识
	 */
	private final Integer code;

	/**
	 * 别名
	 */
	private final String alias;

	private MerchantTradeType(Integer code, String alias) {
		this.code = code;
		this.alias = alias;
	}

	public Integer getValue() {
		return code;
	}

	/**
	 * 枚举标识
	 *
	 * @return code
	 */
	public Integer getCode() {
		return code;
	}

	/**
	 * 别名
	 *
	 * @return alias
	 */
	public String getAlias() {
		return alias;
	}

	/**
	 * 把code转化为费用类型枚举
	 *
	 * @param code 代码
	 * @return
	 */
	@JsonCreator
	public static MerchantTradeType from(Integer code) {
		if (code == null) {
			return null;
		}
		return CODE_MAP.get(code);
	}

	/**
	 * Code Map for MerchantTradeType
	 */
	private static final Map<Integer, MerchantTradeType> CODE_MAP = Stream.of(MerchantTradeType.values())
			.collect(Collectors.toMap(MerchantTradeType::getCode, e -> e));

}
